package com.snake.design.pe.singleton;

/**
 * 
 * 单例就是私有化构造器+静态方法对外暴露
 */
// 懒汉式
class A {
	private static A a = null;

	private A() {
		super();
	}

	public static A getInstance() {
		if (a == null) {
			A a = new A();
			return a;
		}
		return a;
	}

}

// 饿汉式
class B {
	private static B b = new B();

	private B() {
	}

	public static B getInstance() {
		return b;
	}
}